package org.musicsweet.controller;

import org.musicsweet.anotation.AuthReq;
import org.musicsweet.entity.MusicSong;
import org.musicsweet.entity.MusicSong;
import org.musicsweet.result.ResultData;
import org.musicsweet.service.MusicSongService;
import org.musicsweet.service.MusicSongService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 歌曲Controller
 */
@RestController
@RequestMapping("/musicSong")
public class MusicSongController {

    @Autowired
    private MusicSongService musicSongService;

    /**
     * 根据id查询歌曲
     *
     * @param musicSong
     * @return
     */
    @AuthReq
    @RequestMapping("/getMusicSongById")
    public ResultData<MusicSong> getMusicSongById(@RequestBody MusicSong musicSong) {
        return musicSongService.getMusicSongById(musicSong);
    }

    /**
     * 多条件查询歌曲
     *
     * @param musicSong
     * @return
     */
    @AuthReq
    @RequestMapping("/getMusicSongList")
    public ResultData<List<MusicSong>> getMusicSongList(@RequestBody MusicSong musicSong) {
        return musicSongService.getMusicSongList(musicSong);
    }


    /**
     * 添加歌曲
     *
     * @param musicSong
     * @param token
     * @return
     */
    @RequestMapping("/addMusicSong")
    public ResultData addMusicSong(@RequestBody MusicSong musicSong, String token) {
        return musicSongService.addMusicSong(musicSong, token);
    }


    /**
     * 修改歌曲
     *
     * @param musicSong
     * @param token
     * @return
     */
    @RequestMapping("/updateMusicSong")
    public ResultData updateMusicSong(@RequestBody MusicSong musicSong, String token) {
        return musicSongService.updateMusicSong(musicSong, token);
    }


    /**
     * 删除歌曲
     *
     * @param musicSong
     * @return
     */
    @RequestMapping("/delMusicSong")
    public ResultData delMusicSong(@RequestBody MusicSong musicSong) {
        return musicSongService.delMusicSong(musicSong);
    }

}